/*---!!!--- HIGHCHARTS GRAPH ---!!!---*/
// For more information visit docs.highcharts.com/#preprocessing-data-from-a-file
// 	GLOBAL VARIABLES
	const chartLength = 13; 
//	END GLOBAL VARIABLES
function getDevice() {
	return ($(window).height()
		
)};

var dH = getDevice()-68;				// device screen height - header and footer

//HIGHSTOCKS
$(document).on('pageshow', '#msa01', function(){    
    var chart;
    $(document).ready(function() {
		$.get('http://uwfsunchaser.com/haas.php?get_param=value', function (data) {
			var lines = data.split("~");
			
			// Iterate over the lines and add categories or series
			   $.each(lines, function(lineNo, line) {
					var items = line.split('=');	
				   if (lineNo == 0) {
						$.each(items, function(columnNo, item) {
								options.xAxis.categories.push(item);
							
						});
				   }
				});
				
				$('#container').highcharts('StockChart', {
					rangeSelector: {
						selected: 1
					},
					title: {
						text: 'App',
					},
				series: [{
						data: data,
						tooltip: {
							valueDecimals: 2
						}
				}]
					
				});
				
				

		 });
	});
});



// HIGHCHART


$(document).on('pageshow', '#empLM', function(){    
    var chart;
    $(document).ready(function() {

var options = {
	
    chart: {
        renderTo: 'container1',
        defaultSeriesType: 'line',
		marginLeft: 45,							//	sets left margin
		marginRight: 25,	
		zoomType: 'x',
		marginBottom: 50,
		height: dH,
		
    },
	plotOptions: {
				line:{							// change to what ever the type is set to
					marker: {
						enabled: false			// gets ride of points on the line
					}
				}
	},
    title: {
        text: 'Panama City Employment Rate'
    },
    xAxis: {
		type: 'datetime',
        categories: [ ],
		gridLineWidth: 1,
			labels: {
				align: 'center',				//	aligns x axis labels to the left
				rotation: 0,
				step: 4,						// displayes every n'th tick label
				y: 20,
				//x: -10,	
			},
			
   	},
    yAxis: {
        title: {
            text: 'Employment Rate (%)',
			x: 5,								//	moves text in x direction
        },
		labels: {								//	aligns x axis labels to the left
				rotation: 0,
				x: -8,							//	shifts tick labels in x direction
		},
    },
	
	legend:{
		margin: 20,
		enabled: false,							// disables legend box
	},
	
    series: [ ]
	
};

//
$.get('http://uwfsunchaser.com/haas.php?get_param=value', function (data) 
{
	var lines = data.split("~");
	
    // Iterate over the lines and add categories or series
   $.each(lines, function(lineNo, line) {
        var items = line.split('=');	
       if (lineNo == 0) {
		   
            $.each(items, function(columnNo, item) {
				
               /* if (columnNo < chartLength && columnNo %4 == 0) {*/ 
					options.xAxis.categories.push(item);
				/*}else if(columnNo < chartLength) {
					options.xAxis.categories.push('');
			}*/
			});
        }  // end if statement
		
	
        else if (lineNo == 1){
			var series = {data: [ ]};
				$.each(items, function(rowNo, item) 
						{
							if (rowNo < chartLength) {
							series.data.push(parseFloat(item));	// parses a string and returns number as a number not a string
						};
				});//end of $.each
				
				options.series.push(series);
				
		}
        // the rest of the lines contain data with their name in the first position
       /* else {
	
            var series = {data: [ ]};
				$.each(items, function(rowNo, item) 
						{
					if (itemNo == 0) 
						{
						series.name = item;
						} else {
						series.data.push(parseFloat(item));
								}
							if (rowNo < chartLength) {
							series.data.push(parseFloat(item));	// parses a string and returns number as a number not a string
						};
				});//end of $.each
				
				options.series.push(series);
    
        }//end of else*/
        
    });	//end of $.each
	
// vertical auto resize    
	/*$(window).resize(function() {
		chart.setSize(
			$(document).width(),
			$(document).height(),
			false
		);
	});*/
    // Create the chart
    var chart = new Highcharts.Chart(options);
});  //end of $.get

	});
});
	
		